package gui.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.LayoutManager;

import javax.swing.JPanel;

public class ContentPane extends JPanel {
	private static final long serialVersionUID = -8613915282068047206L;
	private NorthPanel northPanel;

	private PlayingField playingField;
	private SouthPanel southPanel;

	public ContentPane() {
		super();
		this.setBackground(Color.LIGHT_GRAY);
		this.setLayout(new BorderLayout());
		this.add(this.getNorthPanel(), BorderLayout.NORTH);
		this.add(this.getPlayingField(), BorderLayout.CENTER);
		this.add(this.getSouthPanel(), BorderLayout.SOUTH);

	}

	public ContentPane(boolean isDoubleBuffered) {
		super(isDoubleBuffered);
		// TODO Auto-generated constructor stub
	}

	public ContentPane(LayoutManager layout) {
		super(layout);
		// TODO Auto-generated constructor stub
	}

	public ContentPane(LayoutManager layout, boolean isDoubleBuffered) {
		super(layout, isDoubleBuffered);
		// TODO Auto-generated constructor stub
	}

	private NorthPanel getNorthPanel() {
		if (this.northPanel == null) {
			this.northPanel = new NorthPanel();
			this.getNorthPanel().addPropertyChangeListener(
					this.getPlayingField());
		}
		return this.northPanel;
	}

	private PlayingField getPlayingField() {
		if (this.playingField == null) {
			this.playingField = new PlayingField();
		}
		return this.playingField;
	}

	private SouthPanel getSouthPanel() {
		if (this.southPanel == null) {
			this.southPanel = new SouthPanel();
			this.getSouthPanel().addPropertyChangeListener(
					this.getPlayingField());
		}
		return this.southPanel;
	}
}
